from time import time
from Tkinter import LEFT
from Tkinter import Tk, Canvas

def motion_cmd(event):
   t = time()
   dt = t - motion_cmd.time
   motion_cmd.x, motion_cmd.y = event.x, event.y
   dy = event.y-motion_cmd.y
   print dy, dt, float(dy)/dt
   motion_cmd.y = event.y
   motion_cmd.time = t 
   
motion_cmd.time = time()
motion_cmd.x=0
motion_cmd.y=0
   
root = Tk()
root.geometry('400x400+100+100')
w=Canvas(root, bg='green', width=200, height=400)
w.pack(side=LEFT)
w.bind('<Motion>', motion_cmd) 
w=Canvas(root, bg='red', width=200, height=400)
w.pack(side=LEFT)
root.mainloop()
